package com.inspiration.utils;

import org.springframework.boot.system.ApplicationHome;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * @Description
 * @Author Vincent.jiao
 * @Date 2023/11/16 17:06
 */
public class PathUtils {
    public static String getLocalhostRoot() throws FileNotFoundException {
//        return ResourceUtils.getURL("classpath:").getPath();
        ApplicationHome home = new ApplicationHome(PathUtils.class);
        File jarFile = home.getSource();
        String path = jarFile.getParentFile().getPath();
        return path + File.separator;
    }

    public static String getDBBackup() throws FileNotFoundException {
        return getLocalhostRoot() + "backupDB";
    }

    public static String getFilePath() throws FileNotFoundException {
        return getLocalhostRoot() + "uploadfile";
    }
}
